package task4;

import java.util.Scanner;

public class Task1 {

    public static void printMatrix(int[][] matrix) {
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[i].length; j++)
                System.out.print(matrix[i][j] + " ");
            System.out.println();
        }
    }
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();

            int[][] matrix = new int[n][n];
            for(int i = 0; i< n; i++){
                for (int j = 0 ; j < n; j++){
                    matrix[i][j] = sc.nextInt();
                }
            }

            rotate(matrix);
            printMatrix(matrix);
        }

        /* 请在这里填写答案 */
    public static void rotate(int[][] matrix){

        if (matrix == null) {
            return;
        }
        int n = matrix.length;
        for (int i = 0; i < n / 2; i++) { //绕各个顶点旋转 所以顶点不用算在内
            for (int j = i; j < n - 1 - i; j++) { //我们每次只交换一个元素，而且一次就把元素交换到旋转以后的位置
                int temp = matrix[i][j];
                matrix[i][j] = matrix[n-1-j][i];//左下角
                matrix[n-1-j][i] = matrix[n-1-i][n-1-j];//右下角
                matrix[n-1-i][n-1-j] = matrix[j][n-1-i];//右上角
                matrix[j][n-1-i] = temp;//左上角
            }
        }


    }
}
